Skip to main content
Version: 6.0.0-beta.3 - 6.0.0-beta.4

setPrivateKey

Set a private key used with the TronWeb instance, used for obtaining the address, signing transactions, and getting balances.

❗️WARNING :

Do not use this with any web/user facing TronWeb instances. This will leak the private key.

Usage

TronWeb.setPrivateKey(private key);

Parameters

ParameterDescriptionData Type
private keyThe private key to be setString

Returns

No return value

Example

>tronWeb.setPrivateKey('AD71C52E0FC0AB0DFB13B3B911624D4C1AB7BDEFAD93F36B6EF97DC955577509');
undefined
> tronWeb.defaultPrivateKey
'AD71C52E0FC0AB0DFB13B3B911624D4C1AB7BDEFAD93F36B6EF97DC955577509'